// components/stars/stars.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    grade:{
      type:Number,
      value:0
    },
    textSize:{
      type:Number,
      value:22
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    intGrade:0
  },

  /**
   * 组件的方法列表
   */
  methods: {

  },
  lifetimes: {
    attached(){
      let that = this;
      // console.log(that.properties.grade)
      let grade = that.properties.grade;
      let full = parseInt(grade/2);
      let half = parseInt(grade%2);
      let empty = 5-full-half;

      let fulls = [];
      let halfs = [];
      let emptys = [];

      let gradetext = (grade === 0)? "无评分":grade;

      for(let i=1;i<=full;i++){
        fulls.push(i);
      }
      for(let i=1;i<=half;i++){
        halfs.push(i);
      }
      for(let i=1;i<=empty;i++){
        emptys.push(i);
      }

      that.setData({
        fulls:fulls,
        halfs:halfs,
        emptys:emptys,

        gradetext:gradetext
      }) 
    } 
  }
})
